package com.dgut.exp02.czqqq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

@Component
public class MyListener implements ApplicationListener<MyEvent> {

    /**
     * 日志变量log
     */
    private static final Logger log = LoggerFactory.getLogger(MyListener.class);

    @Override
    public void onApplicationEvent(MyEvent event) {
        log.info("事件监听器监听到自己创建的 MyEvent 休眠3秒钟观察");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("MyEvent的msg为：" + event.getMsg());

    }
}
